package collection;

import java.util.ArrayList;
import java.util.Collection;
import java.util.Iterator;

//泛型
public class GenericDemo {
    public static void main(String[] args) {
        Collection<Point> p = new ArrayList<>();
        p.add(new Point(1,2));
        p.add(new Point(3,4));
        p.add(new Point(5,6));
        p.add(new Point(7,8));

        Iterator<Point> it = p.iterator();
        while (it.hasNext()){
            Point a = it.next();
            System.out.println(a);
        }
        for (Point point : p) {
            System.out.println(point);
        }












        /*Collection<String> c = new ArrayList<>();//泛型集合
        c.add("one");
        c.add("two");
        c.add("three");
        c.add("four");
        c.add("five");
        Iterator<String> it = c.iterator();
        while (it.hasNext()){
            String str = it.next();
            System.out.println(str);
        }
        for (String s : c) {
            System.out.println(s);
        }*/
    }
}
